package com.zcx.qshop.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zcx.qshop.R;
import com.zcx.qshop.QSApplication;
import com.zcx.qshop.dialog.ScreenDialog;

import java.util.List;

/**
 * Created by Administrator on 2015/8/29 0029.
 */
public class ScreenAdapter extends QSAdapter<ScreenDialog.Screen> {

    private LayoutInflater layoutInflater;

    public ScreenAdapter(Context context, List<ScreenDialog.Screen> objects) {

        super(context, objects);

        layoutInflater = ((Activity)context).getLayoutInflater();

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        TextView name;

        if(convertView == null){

            convertView = QSApplication.ScaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_screen, null));

            convertView.setTag(name = (TextView) convertView.findViewById(R.id.item_screen_name));

        }else{

            name = (TextView) convertView.getTag();

        }

        name.setText(getItem(position).name);

        return convertView;

    }

}
